// /* pages/activity/index/index.js */
// import { activityList } from "../../../utils/data/tabbar";

Page({
    data: {
        statusBarHeight: 0,
        titleBarHeight: 0,
        ceilingFlag: false,
        // activityList, // 列表数据
        activityList: getApp().activityData, // 列表数据
        isLineData: 0,
    },
    input: function(e) {
        this.setData({ keywords: e.detail.value })
    },
    getInputVal: function() {
        let data = getApp().activityData,
            keyword = this.data.keywords,
            array = [],
            len = 0;
        data.map((item, index) => {
            array[index] = item.filter(array => array.title.match(keyword))
        });
        array.map(item => { len += item.length; });
        this.setData({
            activityList: array,
            isLineData: len > 4 ? 2 : 0,
            dataLength: len
        });
    },
    onLoad: function (options) {
        let data = getApp().statusBarHeight,
            list =  getApp().activityData,
            len = 0;
        list.map(item => {
            len += item.length;
        })
        this.setData({
            statusBarHeight: Number(data.statusBarHeight),
            titleBarHeight: data.system.indexOf('IOS') > -1 ? 48 : 44,
            isLineData: len > 4 ? 2 : 0,
            activityList: list,
            dataLength: len
        })
    },
    // 页面滚动
    onPageScroll: function(e) {
        let scrollTop = e.scrollTop;
        if(scrollTop > 50) this.setData({ ceilingFlag: true });
        if(scrollTop < 50) this.setData({ ceilingFlag: false });
    }
});